package cn.com.cym.gamezao.web.recruit;


import cn.com.cym.gamezao.annotation.AuthToken;
import cn.com.cym.gamezao.base.SearchPage;
import cn.com.cym.gamezao.service.recruit.UserApplyService;
import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import org.springframework.http.ResponseEntity;
import org.springframework.lang.NonNull;
import org.springframework.web.bind.annotation.*;

@Api(tags = "r-岗位相关")
@RestController
@RequestMapping(value = "user_apply")
@AuthToken(rule = "recruit.userApply")
public class UserApplyController {
    final UserApplyService thisService;

    UserApplyController(UserApplyService thisService){
        this.thisService = thisService;
    }


    @ApiImplicitParam(name = "searchPage", value = "searchPage", required = true,dataType = "SearchPage")
    @ApiOperation(value = "分页显示page！")
    @ApiOperationSupport(order = 4, author = "mr.chen")
    @PostMapping("/ownPage")
    @AuthToken(rule = "search",require = false)
    public ResponseEntity<?> page(@RequestBody SearchPage searchPage) {
        return
                ResponseEntity.ok(this.thisService.ownPage(searchPage));
    }

    @ApiImplicitParam(name = "searchPage", value = "searchPage", required = true,dataType = "SearchPage")
    @ApiOperation(value = "分页显示page！")
    @ApiOperationSupport(order = 4, author = "mr.chen")
    @PostMapping("/allPage")
    @AuthToken(rule = "search",require = false)
    public ResponseEntity<?> allPage(@RequestBody SearchPage searchPage) {
        return
                ResponseEntity.ok(this.thisService.findByPageable(searchPage));
    }

    @ApiImplicitParam(name = "searchPage", value = "searchPage", required = true,dataType = "SearchPage")
    @ApiOperation(value = "分页显示page！")
    @ApiOperationSupport(order = 4, author = "mr.chen")
    @DeleteMapping("/logic/{id}")
    @AuthToken(rule = "delete",require = false)
    public ResponseEntity<?> logicDelete(@PathVariable @NonNull Long id) {
        this.thisService.logicDelete(id);
        return ResponseEntity.ok().build();
    }
}
